// 子模块moduleA路径：store/modules/moduleA.js 
export default {
	// namespaced: true,
	state: {
		carList: []
	},
	getters: {

	},
	mutations: {
		addToCarList(state, payload) {
			const item = state.carList.find(v => v._id === payload._id);
			if (item) {
				item.count++
			} else {
				state.carList.push(payload)
			}

			console.log(state.carList)
		},
		subToCarList(state, payload) {
			const item = state.carList.find(v => v._id === payload._id);
			if (item) {
				item.count--
			}
			console.log(state.carList)
		},
		changeCarListState(state, payload) {
			const item = state.carList.find(v => v._id === payload._id);
			if (item) {
				item.state = !item.state
			}
			console.log(state.carList)
		},
		changeAllCarListState(state, payload) {
			state.carList.forEach(v => v.state = payload)
	
		}
	},
	actions: {

	}
}